﻿#ifndef QTERMINALCHAR_H
#define QTERMINALCHAR_H

#include <QColor>
#include <QFont>
#include <QObject>
#include <QDataStream>
#include <QMap>
class  qTerminalFont
{

public:

     qTerminalFont()
     {
         this->background = QColor(Qt::black);
         this->foreground =  QColor(Qt::white);
     }
     qTerminalFont(QColor background,QColor foreground)
     {
         this->background = background;
         this->foreground = foreground;
     }

     qTerminalFont& operator=(const qTerminalFont& s)
     {
         this->background = s.background;
         this->foreground = s.foreground;
         this->_b_bold=s._b_bold;//是否加粗
         this->_b_italic=s._b_italic;//是否斜体
         this->_b_strikeout=s._b_strikeout;//是否删除线
         this->_b_underLine=s._b_underLine;//是否下划线
         return *this;
     }
     friend QDataStream & operator<<(QDataStream &stream, const qTerminalFont & info)
     {
         stream <<info.background;
         stream <<info.foreground;

         stream <<info._b_bold;
         stream <<info._b_italic;

         stream <<info._b_strikeout;
         stream <<info._b_underLine;

         return stream;
     }

     friend QDataStream & operator>>(QDataStream &stream, qTerminalFont &info)
     {
         stream >>info.background;
         stream >>info.foreground;

         stream >>info._b_bold;
         stream >>info._b_italic;

         stream >>info._b_strikeout;
         stream >>info._b_underLine;
         return stream;
     }

public :
    QColor background;
    QColor foreground;
    bool   _b_bold=false;//是否加粗
    bool   _b_italic=false;//是否斜体
    bool  _b_strikeout=false;//是否删除线
    bool   _b_underLine=false;//是否下划线

};



class qTerminalChar
{

public:
    qTerminalChar();
    ~qTerminalChar(){

    }
    qTerminalChar(char ch);
    qTerminalChar& operator=(const qTerminalChar& s)
    {
        this->terminalFont = s.terminalFont;

        this->ch=s.ch;//是否加粗
        return *this;
    }
    qTerminalFont terminalFont;
    char ch;

    void setFont(qTerminalFont *pTerminalFont);
    friend QDataStream & operator<<(QDataStream &stream, const qTerminalChar & info)
    {
        stream << info.terminalFont;

        stream <<(quint8)info.ch;

        return stream;
    }

    friend QDataStream & operator>>(QDataStream &stream, qTerminalChar &info)
    {
        quint8 ch;
        stream >> info.terminalFont;
        stream >>ch;
        info.ch = ch;
        return stream;
    }
    //setFont(qTerminalFont *pTerminalFont);
};



#endif // QTERMINALCHAR_H
